import React from "react";
import { messages } from "share/common";
import { Button, Popconfirm, Popover } from "antd";
import configureStore from "stores/index";

export default {

  getBatchButtons: props => {
    const { invoices, deleteFunc, checkFunc } = props;
    return [{
      render: () => {
        return invoices.some(item => item.entityType === 'invoice') ? (
          <Popover content={messages('expense-15.key93')/*不可批量删除员工录入的发票*/}>
            <Button disabled style={{ float: 'left' }}>
              {messages('expense-15.key94')/*删除发票*/}
            </Button>
          </Popover>
        ) : (
          <Popconfirm
            title={messages('expense-15.key95',{arg1: invoices.length})/*删除 {arg1} 笔发票*/}
            onConfirm={() => deleteFunc && deleteFunc()}
          >
            <Button className="delete-btn">
              {messages('expense-15.key94')/*删除发票*/}
            </Button>
          </Popconfirm>
        )
      }
    }, {
      render: () => {
        return !invoices.some(item => item.checkTag !== 'NOT_MATCHED') ? (
          <Popover content={messages('expense-15.key96')/*所选发票均为未匹配状态，无需修改*/}>
            <Button disabled style={{ float: 'left' }}>
              {messages('expense-15.key97')/*发票未匹配*/}
            </Button>
          </Popover>
        ) : (
          <Popconfirm
            title={messages('expense-15.key98',{arg1: invoices.length})/*{arg1}笔发票更新为未匹配*/}
            onConfirm={() => checkFunc && checkFunc('NOT_MATCHED')}
          >
            <Button type="primary">
              {messages('expense-15.key97')/*发票未匹配*/}
            </Button>
          </Popconfirm>
        )
      }
    }, {
      render: () => {
        return !invoices.some(item => item.checkTag !== 'CHECKED') ? (
          <Popover content={messages('expense-15.key99')/*所选发票均为已核对状态，无需修改*/}>
            <Button disabled style={{ float: 'left' }}>
              {messages('expense-15.key100')/*发票已核对*/}
            </Button>
          </Popover>
        ) : (
          <Popconfirm
            title={messages('expense-15.key101',{arg1: invoices.length})/*{arg1} 笔发票更新为已核对*/}
            onConfirm={() => checkFunc && checkFunc('CHECKED')}
          >
            <Button type="primary">
              {messages('expense-15.key100')/*发票已核对*/}
            </Button>
          </Popconfirm>
        )
      }
    }]
  },

  moreButtonList: (formType) => {
    const config = configureStore.store.getState().login.options.auditBaseConfig || {};
    let arr = config[formType === 3004 ? 'corpBillReviewMoreOperateList' : 'billReviewMoreOperateList'] || [];
    if (arr.includes('approveTransfer')) {
      arr.splice(arr.indexOf('approveTransfer'), 1, 'autoTransfer')
    }
    return arr;
  },

};
